#输入一个链表，输出该链表中倒数第k个结点。

class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None

def get_reverse_k(head,k):
    my_list = []
    while head:
        my_list.append(head)
        head = head.next
    if k > len(my_list) or k < 1:
        return
    return my_list[-k]


node1 = ListNode(1)
node2 = ListNode(2)
node3 = ListNode(3)
node4 = ListNode(4)
node5 = ListNode(5)
node1.next=node2
node2.next=node3
node3.next=node4
node4.next=node5

print(get_reverse_k(node1,{}).val)